﻿using UnityEngine;
using System.Collections;

/// <summary>
/// This script makes camera watch/stalk the player
/// Thus moving the camera's position based on where the player is
/// </summary>

public class PlayerWatcher : MonoBehaviour {
	public GameObject playerToBeWatched;
	public float cameraLeftPositionLimit = 6.75f;
	public float cameraRightPositionLimit = 29.3f;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		//assume not null
		if(playerToBeWatched.transform.position.x >= cameraLeftPositionLimit && playerToBeWatched.transform.position.x <= cameraRightPositionLimit){
			this.transform.position = new Vector3(playerToBeWatched.transform.position.x, this.transform.position.y, this.transform.position.z);
		}
	}
}
